/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * Portions created by the Initial Developer are
 * Copyright (C) 2012 the Initial Developer.
 * All Rights Reserved.
 *
 * The Original Code is "http://semi-frame.googlecode.com/svn/trenk/".
 *
 * The Initial Developer of the Original Code is the author below.
 */
/**
 * @file DateUtil.h
 * @brief Utility of date.
 * @author mornongcloud
 * @date 2011/11/21
 */

#ifndef SEMIUTILDATEUTIL_H_
#define SEMIUTILDATEUTIL_H_

#include <time.h>
#include "UtilBase.h"

namespace semi {
namespace util {

/**
 * @brief Date and time utility class.
 */
class DateUtil {
public:
	///@brief default constructor.
	DateUtil();

	DateUtil(long long secdatetime);

	DateUtil(int y, int m, int d, int h, int min, int s);

	DateUtil(std::string YYYYMMDDHH24MISS);

	///@brief destructor.
	virtual ~DateUtil();

	void setCurrent();
	long long getCurrent();
	void setTime(long long time);
	long long getTime();

	int getYear();
	int getMonth();
	int getDay();
	int getHour();
	int getMin();
	int getSec();

	std::string getMonthString();
	std::string getDayString();
	std::string getHourString();
	std::string getMinString();
	std::string getSecString();

	std::string getYYYYMMDDHH24MI();
	std::string getYYYYMMDDHH24MISS();

private:
	time_t timer;
	struct tm *date;
	void setTime(int y, int m, int d, int h, int min, int s);
};

}
}

#endif /* SEMIUTILDATEUTIL_H_ */
